package com.since.data_structure.queue;

import java.util.Scanner;

/**
 * Created by Sincerity on 2020/5/6.
 * 描述：
 */
public class QueueTest {
    public static void main(String[] args) {
//        OrdinaryQueue queue = new OrdinaryQueue(5);
        CircularQueue queue = new CircularQueue(4);
        char key = ' ';
        Scanner scanner = new Scanner(System.in);//
        boolean loop = true;
        while(loop) {
            key = scanner.next().charAt(0);
            switch (key) {
                case 's':
                    queue.show();
                    break;
                case 'a':
                    System.out.println("请输入一个数");
                    int value = scanner.nextInt();
                    queue.add(value);
                    break;
                case 'g':
                    try {
                        int res = queue.getQueue();
                        System.out.printf("取出的数是%d\n", res);
                    } catch (Exception e) {
                        // TODO: handle exception
                        System.out.println(e.getMessage());
                    }
                    break;
                case 'h':
                    try {
                        int res = queue.getHeader();
                        System.out.printf("队列的头是%d\n", res);
                    } catch (Exception e) {
                        // TODO: handle exception
                        System.out.println(e.getMessage());
                    }
                    break;
                case 'e':
                    scanner.close();
                    loop = false;
                    break;
                default:
                    break;
            }
        }
    }
}
